package psd.model.Prolog.Converters;

import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.SingleMemberAnnotation;

import psd.model.IConverter;
import psd.model.Prolog.FactGenerationToolbox;
import psd.model.Prolog.PrologConverter;


public class PrologSingleMemberAnnotationConverter extends PrologConverter
		implements IConverter<SingleMemberAnnotation> {

	public PrologSingleMemberAnnotationConverter(
			FactGenerationToolbox toolbox) {
		super(toolbox);
	}

	@Override
	public boolean convert(SingleMemberAnnotation node) {
		String valueId = idResolver.getID();
		setRelinkedParentId(node.getValue(), valueId);
		checkAndGenComments(node, valueId);
		writer.writeFact("memberValueT", new String[] { valueId,
				idResolver.getID(node), quote("null"),
				idResolver.getID(node.getValue()), this.getFilePath(node), this.getLineNumber(node) });
		visitAnnotation(node, (new StringBuilder("[")).append(valueId).append(
				"]").toString());
		return true;
	}

	private void setRelinkedParentId(ASTNode obj, String valueId) {
		relinkedParents.put(obj, valueId);
	}

}
